package com.beinhospital_sw21_h2_05.beinhospitalsw21h205.mapper;

import com.beinhospital_sw21_h2_05.beinhospitalsw21h205.entity.Clerk;
import com.beinhospital_sw21_h2_05.beinhospitalsw21h205.entity.Linshi3;
import com.beinhospital_sw21_h2_05.beinhospitalsw21h205.entity.UserTable;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * MyBatis Mapper接口，用于与数据库表Clerk和UserTable进行交互
 */
@Mapper
public interface ClerkMapper {

    /**
     * 查询收费员信息
     * @param clerkName 收费员姓名
     * @return 收费员列表
     */
    List<Linshi3> list(String clerkName);

    /**
     * 根据收费员ID删除收费员
     * @param clerkID 收费员ID
     */
    @Delete("delete from Clerk where clerkID = #{clerkID}")
    void delete(Integer clerkID);

    /**
     * 插入收费员信息
     * @param clerk 收费员对象
     */
    @Insert("insert into Clerk(UserID,ClerkName) values(#{UserID},#{ClerkName})")
    void insert(Clerk clerk);

    /**
     * 更新收费员信息
     * @param clerk 收费员对象
     */
    @Update("update Clerk set ClerkName = #{ClerkName} where clerkID = #{clerkID}")
    void update(Clerk clerk);

    /**
     * 插入用户信息
     * @param user 用户对象
     */
    @Insert("insert into UserTable(Username,Password,Role) values(#{Username},#{Password},#{Role})")
    void insertUser(UserTable user);

    /**
     * 根据用户名查询用户ID
     * @param username 用户名
     * @return 用户ID
     */
    @Select("select UserID from UserTable where Username = #{username}")
    Integer getUserID(String username);

    /**
     * 根据收费员ID查询用户ID
     * @param clerkID 收费员ID
     * @return 用户ID
     */
    @Select("select UserID from Clerk where ClerkID = #{clerkID}")
    Integer getUserID2(Integer clerkID);

    /**
     * 更新用户信息
     * @param user 用户对象
     */
    @Update("update UserTable set Username = #{Username},Password = #{Password} where UserID = #{UserID}")
    void updateUser(UserTable user);

    /**
     * 根据用户ID删除用户
     * @param userID 用户ID
     */
    @Delete("delete from UserTable where UserID = #{user}")
    void deleteUser(Integer userID);
}
